home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '90 / MacHack'90 Proceedings / John Norstad / Reusable Code / Source / glob.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-10  |  10.9 KB  |  283 lines  |  [TEXT/MPS ]

  1. /*______________________________________________________________________
  2.  
  3.     glob.h - Global Declarations for Disinfectant.
  4.     
  5.     Copyright © 1988, 1989, 1990 Northwestern University.  Permission is 
  6.     granted to use this code in your own projects, provided you give credit 
  7.     to both John Norstad and Northwestern University in your about box or 
  8.     document.
  9.  
  10.     This header file defines the constants, data types, and global
  11.     variables shared by the private modules in Disinfectant.
  12.  
  13.     Note that the reusable modules are not permitted to include the
  14.     header file, but the virus detection and repair modules are permitted
  15.     to include it.    
  16. _____________________________________________________________________*/
  17.  
  18.  
  19. #ifndef __glob__
  20. #define __glob__
  21.  
  22. #ifndef __rpp__
  23. #include "rpp.h"
  24. #endif
  25.  
  26. #ifndef __rez__
  27. #include "rez.h"
  28. #endif
  29.  
  30.  
  31. /*______________________________________________________________________
  32.  
  33.     Constant Definitions. 
  34. _____________________________________________________________________*/
  35.  
  36.  
  37.  
  38. /* System constants. */
  39.  
  40. #define    fcbMdRByt            4            /* offset in FCB of flags byte */
  41. #define    rMapFRefNum            20            /* offset to file ref num in rsrc map */
  42. #define    rMapRFAttr            22            /* offset to file attrs in rsrc map */
  43. #define    rfRMapOff            4            /* offset in resource file to offset to
  44.                                                     resource map */
  45.  
  46. /* Other constants. */
  47.  
  48. #define    spinInterval        10            /* spin cursor every 10 ticks */
  49. #define  invertInterval       15            /* tick interval between inverts of
  50.                                                     small floppy icon during scan of
  51.                                                     floppy sequence */
  52. #define    zoomSlop                3            /* pixels to leave at top and bottom
  53.                                                     of zoomed windows */
  54. #define    staggerInitialOffset    3        /* pixel offset for first staggered window */
  55. #define    staggerOffset        20            /* pixel offset for subsequent staggered
  56.                                                     windows */
  57. #define    dragSlop                4            /* slop for DragWindow bounds rect */
  58. #define    minMainSize            295        /* min height of main window in pixels */
  59. #define    minHelpSize            100        /* min height of Help window in pixels */
  60. #define    beepDuration        10            /* sysbeep duration in ticks */
  61.  
  62. /* Tags for help system */
  63.  
  64. #define    tagFirstButton    300        /* first button - the other buttons
  65.                                                 are assigned tags 301 through 309 */
  66. #define    tagUpperRight    320        /* upper right corner of main window */
  67. #define    tagReport        321        /* report rectangle */
  68. #define    tagMainWind        500        /* main window */
  69. #define    tagHelpWind        501        /* help window */
  70. #define    tagPrefBeep        330        /* prefs beep option */
  71. #define    tagPrefStation    331        /* prefs scanning station option */
  72. #define    tagPrefSave        332        /* prefs saved text file options */
  73. #define    tagPrefNotif    333        /* prefs notification options */
  74. #define    tagAbouWind        503        /* about window */
  75. #define    tagCmdBase        600        /* base for menu commands */
  76. #define    tagCmdMult        20            /* multiplier for menu commands */
  77.  
  78. /*______________________________________________________________________
  79.  
  80.     Type Declarations.
  81. _____________________________________________________________________*/
  82.  
  83.  
  84. /* Kinds of scans. */
  85.  
  86. typedef enum ScanKind {
  87.     allScan,                    /* all volumes */
  88.     volScan,                    /* selected volume */
  89.     foldScan,                /* folder */
  90.     fileScan,                /* file */
  91.     autoScan,                /* sequence of floppies */
  92.     fileFoldScan,            /* file or folder */
  93.     sysFileScan,            /* system file */
  94.     sysFoldScan,            /* system folder */
  95.     volSetScan,                /* set of volumes */
  96. } ScanKind;
  97.  
  98. /* Scanning operations. */
  99.  
  100. typedef enum ScanOp {
  101.     checkOp,                    /* scan */
  102.     disinfectOp,            /* disinfect */
  103. } ScanOp;
  104.  
  105. /* Notification options. */
  106.  
  107. typedef enum NotifOption {
  108.     notifDiamond,            /* only diamond in apple menu */
  109.     notifIcon,                /* also rotating icon in menu bar */
  110.     notifAlert,                /* also alert */
  111. } NotifOption;
  112.  
  113. /* Window kinds. */
  114.  
  115. typedef enum WindKind {
  116.     mainWind,                /* main window */
  117.     helpWind,                /* help window */
  118.     prefWind,                /* prefs window */
  119.     abouWind,                /* about window */
  120.     daWind,                    /* da window */
  121. } WindKind;
  122.  
  123. /* The standard Edit menu commands. */
  124.  
  125. typedef enum EditCmd {
  126.     undoCmd,
  127.     editDummyCmd,    /* the separator line in the Edit menu */
  128.     cutCmd,
  129.     copyCmd,
  130.     pasteCmd,
  131.     clearCmd 
  132. } EditCmd;
  133.  
  134. /* Window objects.  This struct records additional information about each
  135.     window, plus pointers to functions to handle the common window events
  136.     and commands.  The refCon field of each window record points to one
  137.     of these structs. */
  138.  
  139. typedef void (*FUpdate)(void);
  140. typedef void (*FActivate)(void);
  141. typedef void (*FDeactivate)(void);
  142. typedef void (*FClick)(Point where, short modifiers);
  143. typedef void (*FHelp)(Point where);
  144. typedef void (*FGrow)(short height, short width);
  145. typedef void (*FZoom)(void);
  146. typedef void (*FKey)(short key, short modifiers);
  147. typedef void (*FClose)(void);
  148. typedef void (*FDisk)(long message);
  149. typedef Boolean (*FSave)(void);
  150. typedef void (*FPageSetup)(void);
  151. typedef OSErr (*FPrint)(Boolean printOne);
  152. typedef void (*FEdit)(EditCmd cmd);
  153. typedef void (*FAdjust)(void);
  154. typedef void (*FPeriodic)(void);
  155. typedef Boolean (*FDialogPre)(short key);
  156. typedef void (*FDialogPost)(short item);
  157.  
  158. typedef struct WindowObject {
  159.     WindKind                windKind;            /* which kind of window */
  160.     Boolean                moved;                /* true if moved or grown */
  161.     Rect                    sizeRect;            /* size rectangle */
  162.     FUpdate                update;                /* ptr to update function */
  163.     FActivate            activate;            /* ptr to activate function */
  164.     FDeactivate            deactivate;            /* ptr to deactivate function */
  165.     FClick                click;                /* ptr to click function */
  166.     FHelp                    help;                    /* ptr to help function */
  167.     FGrow                    grow;                    /* ptr to grow function */
  168.     FZoom                    zoom;                    /* ptr to zoom function */
  169.     FKey                    key;                    /* ptr to key function */
  170.     FClose                close;                /* ptr to close function */
  171.     FDisk                    disk;                    /* ptr to disk inserted function */
  172.     FSave                    save;                    /* ptr to save function */
  173.     FPageSetup            pageSetup;            /* ptr to page setup function */
  174.     FPrint                print;                /* ptr to print function */
  175.     FEdit                    edit;                    /* ptr to edit function */
  176.     FAdjust                adjust;                /* ptr to menu adjust function */
  177.     FPeriodic            periodic;            /* ptr to periodic function */
  178.     FDialogPre            dialogPre;            /* ptr to dialog event preprocessor */
  179.     FDialogPost            dialogPost;            /* ptr to dialog event postprocessor */
  180. } WindowObject;
  181.  
  182. /* Saved window state.  See HIN 6. */
  183.  
  184. typedef struct WindState {
  185.     Rect                    userState;                /* user state rectangle */
  186.     Boolean                zoomed;                    /* true if in zoomed (standard) state */
  187.     Boolean                moved;                    /* true if moved or grown */
  188. } WindState;
  189.  
  190. /* Preferences. */
  191.  
  192. typedef struct PrefsType {
  193.     char                    version[30];            /* version number */
  194.     WindState            mainState;                /* main window state */
  195.     WindState            helpState;                /* help window state */
  196.     WindState            prefState;                /* prefs window state */
  197.     WindState            abouState;                /* about window state */
  198.     rpp_PrtBlock        mainPrint;                /* main window print block */
  199.     rpp_PrtBlock        helpPrint;                /* help window print block */
  200.     TPrint                mainPrintRec;            /* main window print record */
  201.     TPrint                helpPrintRec;            /* help window print record */
  202.     short                    numOpenWind;            /* number of open windows */
  203.     WindKind                openWind[5];            /* list of open windows, in front to
  204.                                                             back order */
  205.     short                    helpScrollPos;            /* help window scroll position */
  206.     short                    beepCount;                /* beep count pref */
  207.     Boolean                scanningStation;        /* scanning station pref */
  208.     ScanOp                scanningStationOp;    /* scanning station op - 
  209.                                                             scan or disinfect */
  210.     OSType                repCreator;                /* report creator type pref */
  211.     OSType                docCreator;                /* document creator type pref */
  212.     OSType                repOtherCre;            /* report "other" creator type */
  213.     OSType                docOtherCre;            /* doc "other" creator type */
  214.     NotifOption            notifOption;            /* notification option pref */
  215. } PrefsType;
  216.  
  217. /*______________________________________________________________________
  218.  
  219.     Global Variables.
  220. _____________________________________________________________________*/
  221.  
  222.  
  223. /* The following variables are set during initialization, and never
  224.     changed thereafter. */
  225.     
  226. extern ControlHandle    Controls[numControls];    /* main window control handles */
  227. extern Handle            Report;                    /* handle to main window report record */
  228. extern Rect                DragRect;                /* drag rectangle */
  229. extern Boolean            SysHasShutDown;        /* true if shutdown trap exists */
  230. extern long                LongSleep;                /* long sleep time */
  231. extern Rect                RectList[numRects];    /* rectangle list */
  232. extern CursHandle        Watch;                    /* handle to watch cursor */
  233. extern CursHandle        BBCursors[numBalls];    /* handles to beachball cursors */
  234. extern CursHandle        HelpCurs;                /* handle to help cursor */
  235. extern CursHandle        FloppyCurs;                /* handle to floppy disk cursor */
  236. extern short            SysRefNum;                /* system file ref num */
  237. extern short            SysVol;                    /* system vol ref num */
  238. extern long                SysDirID;                /* blessed folder dir id */
  239. extern short            DfectRefNum;            /* Disinfectant's file ref num */
  240. extern short            DfectVol;                /* Disinfectant's vol ref num */
  241. extern Boolean            OldRom;                    /* true if 64K rom */
  242.  
  243. /*    The following variables are changed after intialization. */
  244.                                                     
  245. extern PrefsType        Prefs;                    /* preferences */
  246. extern Boolean            Done;                        /* true when time to quit */
  247. extern Boolean            MenuPick;                /* true if command was via menu pick */
  248. extern Boolean            Scanning;                /* true while scan in progress */
  249. extern Boolean            FloppyWait;                /* true while waiting for floppy insert */
  250. extern Boolean            Canceled;                /* true if scan canceled */
  251. extern Boolean            RepInfected;            /* true if current report contains a 
  252.                                                             message about an infected file */
  253. extern Boolean            SysInfect;                 /* true if at least one file in the currently 
  254.                                                             active system folder was infected on a 
  255.                                                             disinfection run */
  256. extern Boolean            HelpMode;                /* true if help mode */
  257. extern Boolean            InForeground;            /* true if running in foreground */                                                                
  258. extern Boolean            NoMemFullAlert;        /* true to tell grow zone proc to 
  259.                                                             return 0 on mem full instead of 
  260.                                                             posting mem full alert */
  261. extern Boolean            DisableDisinfect;        /* true to disable Disinfect button */
  262. extern short            CurScanKind;            /* kind of scan */
  263. extern long                NumScanned;                /* number of files scanned counter */
  264. extern long                NumInfected;            /* number of files infected counter */
  265. extern long                NumErrors;                /* number of errors counter */
  266. extern Boolean            Notified;                /* true if notification posted */
  267. extern NMRec            NotifRec;                /* Notification Manager record */
  268. extern Str255            NotifString;            /* notification string */
  269. extern Boolean            BBEnabled;                /* true if spinning beachball is enabled */
  270. extern long                TotFiles;                /* total number of files scanned */
  271. extern long                TotErrors;                /* total number of errors */
  272. extern long                TotInfected;            /* total number of infected files */
  273. extern long                TotStillInf;            /* total number of infected files
  274.                                                             not repaired */
  275. extern long                TotNoAccess;                /* total number of folders with 
  276.                                                         insufficient access rights */                                            
  277. extern unsigned long    EarliestDate;            /* date/time of earliest infection */
  278. extern Str255            EarliestName;            /* name of earliest infected file */                                                        
  279. extern Boolean            SysInfected;            /* true if infected file found
  280.                                                             in blessed folder */
  281.  
  282.  
  283. #endif